﻿{include file="public/header"}
<title>问题修改</title>
</head>
<body>

<style>
    .form-label{
        width: 15% !important;
    }
</style>
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" >
        <div class="ch-row ch-info-form">
            <div class="flex1">序号：</div>
            <div class="flex2">
                <input type="text"  name="serial" class="title form-control" value="{$data.serial}" >
                <input type="hidden"  name="detaileds_id" value="{$data.detaileds_id}" >
                <input type="hidden"  name="detailed_id" value="{$data.detailed_id}" >
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">施工项目：</div>
            <div class="flex2">
                <textarea class="form-control" name="detailed_title">{$data.detailed_title}</textarea>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">单位：</div>
            <div class="flex2">
                <select class="form-control" name="un_id">
                    <option selected="selected" value="{$data.un_id}">{$data.title}</option>
                    {volist name='g' id='v'}
                    <option value="{$v.id}">{$v.title}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">人工费：</div>
            <div class="flex2">
                <input type="text" name="artificial" class="form-control title" value="{$data.artificial}">
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">备注：</div>
            <div class="flex2">
                <textarea class="form-control" name="rmakes">{$data.rmakes}</textarea>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">人工结算价：</div>
            <div class="flex2">
                <input type="text" name="pri" class="form-control" value="{$data.pri}">
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">结算备注：</div>
            <div class="flex2">
                <textarea class="form-control" name="pris">{$data.pris}</textarea>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">排序：</div>
            <div class="flex2">
                <input class="form-control" type="text" name="xu" value="{$data.xu}">
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <div class="flex1">关联供应商：</div>
            <div class="flex2">
                <div><input type="text" class="form-control " id="xu" name="xu" style="width: 50%;
    display: inline-block;">
                    <button class="btn btn-primary dian" style="width:27%;    margin-top: 0px;" type="button"><i
                            class="Hui-iconfont">&#xe632;</i> 提交
                    </button>
                </div>

            </div>
        </div>


        <div class="ch-row ch-info-form">

            <div id="lie" style="margin-left: 34%;">
                {if(!empty($agency))}
                {volist name='agency' id='vo'}
                <div class='flex2 guan'><span>{$vo.random_number}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$vo.agency_name}
                </span><input type='hidden' name='agency_id[]' id='id_1' value='1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a>删除</a>
                    {/volist}
                </div>
                {/if}
            </div>
        </div>

        </div>

        <div class="ch-row">
            <div class="flex1">
                <button style="width: 100%;" class="btn btn-primary radius" type="button" ><i class="Hui-iconfont">&#xe632;</i> 提交</button>
            </div>
        </div>



        
        
    </form>
</article>

{include file="public/footer"}
<script>
    $('.radius').click(function () {

        var src="{:Url('index/Detailed/edi')}";
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data:$('form').serializeArray(),
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){


                        layer.closeAll();
                            window.parent.location.reload();


                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });



    });
    $('.dian').click(function () {
        var src = "{:Url('index/Detailed/agency')}";
        var index = $("#xu").val();
        var html = '';
        $.ajax({
            type: 'POST',
            url: src,
            dataType: 'json',
            data: {name: index},
            success: function (data) {
                var res = JSON.parse(data);
                if (res.code == 200) {

                    if (res.data.length > 0) {

                        for (var i = 0; i < res.data.length; i++) {
                            var index = $("#id_" + res.data[i]['agency_id']).val();
                            if (index != res.data[i]['agency_id']) {
                                html += " <div class='flex2 guan' ><span>" + res.data[i]['random_number'] + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + res.data[i]['agency_name'] + "</span><input type='hidden' name='agency_id[]' id='id_" + res.data[i]['agency_id'] + "' value='" + res.data[i]['agency_id'] + "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a>删除</a></div>";
                            }

                        }
                    } else {
                        alert('供应商编号错误或无此供应商')
                    }

                    $('#lie').append(html);
                } else {
                    console.log(res.msg);
                }

            },

        });

    });

    $("#lie").on("click", ".guan", function () {
        var thit = this;
        layer.confirm('确认要删除吗？', {
            btn: ['确定', '取消']//按钮
        }, function (index) {
            layer.close(index);
            $(thit).remove();
            //此处请求后台程序，下方是成功后的前台处理……


        });


    });
</script>
</body>
</html>